<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改项目')" />
    <th:block th:include="include :: summernote-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-project-edit" th:object="${project}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">项目名称：</label>
                <div class="col-sm-8">
                    <input id="name" name="name" th:field="*{name}" class="form-control" placeholder="项目名称不超过20个字"  type="text" required>
                </div>
            </div>
            <div class="form-group" id="empIdDiv">
                <label class="col-sm-3 control-label is-required">负责人：</label>
                <div class="col-sm-8">
                    <div class='input-group'>
                        <input class='form-control' type='hidden'  th:field="*{empId}" name="empId" id='empId' required>
                        <input class='form-control' type='text'  id='userAuditName' th:value="${empUser.name}" readonly="readonly" required>
                        <span class='input-group-addon input-sm' onclick='selectDictTree("", this)'>
                            <i class='fa fa-search'>选择</i>
                        </span>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label is-required">迭代状态：</label>
                <div class="col-sm-8">
                    <select name="status" th:with="type=${@dict.getType('sys_project_status')}"  class="form-control m-b">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{status}"></option>
                    </select>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">描述：</label>
                <div class="col-sm-8">
                    <textarea id="contentDescribe" name="contentDescribe" th:field="*{contentDescribe}" placeholder="给项目写点描述"  class="form-control"></textarea>
                </div>
            </div>

        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: summernote-js" />
    <script th:inline="javascript">
        var statusDatas = [[${@dict.getType('sys_project_status')}]];
        var sysUse = [[${@otherService.getSysUser()}]];
        var prefix = ctx + "project/project";
        $("#form-project-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {

                $.operate.save(prefix + "/edit", $('#form-project-edit').serialize());
            }
        }

        $("#name").keyup(function(){
            var str = $("#name").val();
            if (str.length > 20 ){
                $("#name").val(str.substring(0,20));
                $.modal.alertWarning("字数限制在20字以内");
            }
        });

        $("#contentDescribe").keyup(function(){
            var str = $("#contentDescribe").val();
            if (str.length > 100 ){
                $("#contentDescribe").val(str.substring(0,100));
                $.modal.alertWarning("字数限制在100字以内");
            }
        });

        function selectDictTree(columnId, obj) {
            var url = ctx + "system/user/selectUserTree";
            var options = {
                title: '选择审核人',
                width: "380",
                url: url,
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }

        function doSubmit(index, layero){
            var body = layer.getChildFrame('body', index);
            var userId = body.find('#userId').val();
            var userNameShow = body.find('#userNameShow').val();
            layer.close(index);
            $("#empId").val(userId);
            $("#userAuditName").val(userNameShow);
            // document.getElementById("userName").value=userName;
        }

    </script>
</body>
</html>